<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>二元运算</title>
	</head>
	<body>
		<input name="aaa" type="button" value="四则运算" onclick="yunsuan()" />
		<script type="text/javascript">
			function yunsuan(){
				var num = prompt("请输入第一个数字："," ");
				var num1 = parseInt(num);
				var numb = prompt("请输入第二个数字"," ");
				var num2 = parseInt(numb);
				
				var fuhao = prompt("请输入运算符"," ");
				var jieguo;
				switch(fuhao){
					case "+":
					jieguo = num1+num2;
					break;
					case "-":
					jieguo = num1-num2;
					break;
					case "*":
					jieguo = num1*num2;
					break;
					case "/":
					jieguo = num1/num2;
					break;
					default:
					document.write("输入的运算符不正确！")
					break;
					
				}
				
				alert(num1+" " + fuhao + " " + num2 + "=" +jieguo);
			
			}
			
			
		</script>
	</body>
</html>
